#include "startwidget.h"
#include <QPainter>
#include <QDebug>
#include <QTimer>
#include <QSound>
#include "chooseleavewidget.h"
#include <QMainWindow>
#include "mainscence.h"

startWidget::startWidget(QWidget *parent) : QWidget(parent){
    this->setFixedSize(320, 565);

    MyButton * startBtn = new MyButton(":/resource/MenuSceneStartButton.png", "");
    //将自定义按钮加入MainScene
    startBtn->setParent(this);
//    qDebug() << "开始场景大小：" << this->width() << "高度：" <<this->height();
    startBtn->move(this->width()*0.5-startBtn->width()*0.5, this->height()*0.7);

    QSound * startSound = new QSound(":/resource/TapButtonSound.wav",this);
    connect(startBtn, &QPushButton::clicked,[=](){
        //点击特效
        startSound->play();
        startBtn->zoom1();
//        startBtn->zoom2();

        QTimer::singleShot(160, this, [=](){
            emit sendGotoLevlPane();

        });
    });
}

void startWidget::paintEvent(QPaintEvent *){
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/resource/PlayLevelSceneBg.png");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);

    //加载标题
    pix.load(":/resource/Title.png");
    //缩放
    pix = pix.scaled(pix.width()*0.5, pix.height()*0.5);
    painter.drawPixmap(10,7,pix.width(),pix.height(),pix);

}
